package test.com.sms.selenium.singlepoint.util;

import java.util.Set;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpContractsQuoterAdvancedSearchPageUtil extends
		SeleniumPageUtil {
	
	public final static  By CQA_SPAN_HEAD = By.id("lblHdr");
	public final static  By CQA_TD_TITLE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[1]/tbody/tr/td[2]");
	public final static  By CQA_TD_STATUS = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[1]/td[1]"); 
	public final static  By CQA_CHECKBOX_DRAFT = By.id("ctl04_chkStatusDraft"); 
	public final static  By CQA_LABEL_DRAFT = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[1]/td[2]/label[1]"); 
	public final static  By CQA_CHECKBOX_SUBMIT = By.id("ctl04_chkStatusSubmitted"); 
	public final static  By CQA_LABEL_SUBMIT = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[1]/td[2]/label[2]"); 
	public final static  By CQA_CHECKBOX_WON = By.id("ctl04_chkStatusWon"); 
	public final static  By CQA_LABEL_WON = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[1]/td[2]/label[3]"); 
	public final static  By CQA_CHECKBOX_LOST = By.id("ctl04_chkStatusLost"); 
	public final static  By CQA_LABEL_LOST = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[1]/td[2]/label[4]"); 
	public final static  By CQA_TD_CONTRACTID = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[2]/td[1]");
	public final static  By CQA_INPUT_CONTRACTID = By.id("ctl04_txtContractID");
	public final static  By CQA_TD_MRR = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[2]/td[3]");
	public final static  By CQA_CHECKBOX_MRR = By.id("ctl04_chkTopLevel");
	public final static  By CQA_TD_CUSTOMER = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[3]/td[1]");
	public final static  By CQA_INPUT_CUSTOMER = By.id("ctl04_txtCustName");
	public final static  By CQA_TD_PARTNER = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[3]/td[3]");
	public final static  By CQA_CHECKBOX_PARTNER = By.id("ctl04_chkPartnerFlag");
	public final static  By CQA_TD_END = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[3]/td[5]");
	public final static  By CQA_INPUT_END = By.id("ctl04_txtEndCustName");
	public final static  By CQA_TD_SALE_REP = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[4]/td[1]"); 
	public final static  By CQA_SELECT_SALE_REP = By.id("ctl04_cboSalesRepID");
	public final static  By CQA_TD_CREATE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[4]/td[3]");
	public final static  By CQA_TD_DATE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[4]/td[4]");
	public final static  By CQA_INPUT_CREATE_START = By.id("ctl04_txtStart");
	public final static  By CQA_IMG_CREATE_START = By.id("ctl04_imgStart");
	public final static  By CQA_INPUT_CREATE_STOP = By.id("ctl04_txtStop");
	public final static  By CQA_IMG_CREATE_STOP = By.id("ctl04_imgStop");
	public final static  By CQA_TD_CPO = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[5]/td[1]");
	public final static  By CQA_INPUT_CPO = By.id("ctl04_txtCustPONo");
	public final static  By CQA_TD_OTHER_FIELD = By.id("ctl04_OtherSearch1_lblField");
	public final static  By CQA_SELECT_OTHER_FIELD = By.id("ctl04_OtherSearch1_cboOther");
	public final static  By CQA_TD_OTHER_VALUE = By.id("ctl04_OtherSearch1_lblOther");
	public final static  By CQA_BTN_SAVE = By.id("ctl04_btnSearch");
	public final static  By CQA_BTN_CLEAR = By.id("ctl04_btnClear");
	public static void enter(){
		SpContractsQuoterPageUtil.enter();
		SpContractsQuoterPageUtil.displayHidenMenus(new By[]{SpContractsQuoterPageUtil.STQ_LINK_QUOTER});
		SeleniumUtil.waitOnElements(new By[]{SpContractsQuoterPageUtil.STQ_LINK_QUOTER_SEARCH});
		Set<String> before = SeleniumUtil.getWindowHandles();
		SeleniumUtil.click(SeleniumUtil.getCachedElement(SpContractsQuoterPageUtil.STQ_LINK_QUOTER_SEARCH));
		SeleniumUtil.waitForFixedMilliseconds(15000);
		SeleniumUtil.switchToPromptedWindow(before, SeleniumUtil.getWindowHandles());
		waitForPageToLoad();
	}

	private static void waitForPageToLoad() {
		SeleniumUtil.selectDefaultContent();
//		SmsSeleniumUtil.waitOnElements(new By[]{
//				CQA_TD_TITLE,CQA_SPAN_HEAD
//		});
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQA_TD_TITLE));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQA_SPAN_HEAD));
	}
}
